package com.neusoft.gene.nep.role.controller;

import com.neusoft.gene.nep.entity.CommonResult;
import com.neusoft.gene.nep.role.entity.Roles;
import com.neusoft.gene.nep.role.service.IRolesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description: TODO   角色表 前端控制器
 * @author: 君醉
 * @date: 2024/6/19 16:14
*/

@RestController
@RequestMapping("/role")
@CrossOrigin("*")
public class RolesController {

    @Autowired
    IRolesService rolesService;


    @GetMapping("q/menu/{roleid}")

    public CommonResult  selectMenuByRoleid(@PathVariable("roleid")  Integer  roleid){
        return  rolesService.selectMenuByRoleid(roleid);
    }

    @PutMapping("auth/{rid}" )
    public CommonResult  modRoleAuth(@PathVariable("rid")  Integer  rid,@RequestBody  List<Integer>  sysnodeids){
        return  rolesService.modRoleAuth( rid,sysnodeids);
    }


    @GetMapping("select/sysnodes/{rid}")
/**
 * 所有的系统节点，不包括分支节点
 */
    public CommonResult  selectSysnodesByRid(@PathVariable("rid")  Integer  rid){

        return   rolesService.selectSysnodesByRid( rid);
    }


    @PutMapping("mod")
    public CommonResult  modRole(@RequestBody  Roles  roles){
        return   rolesService.modRole(   roles);
    }


    @PostMapping("new")
    public CommonResult addRole(@RequestBody  Roles  roles){
        return   rolesService.addRole( roles);
    }


    @GetMapping("s/list/all")
    public CommonResult<List<Roles>> listAll(){
        return rolesService.listAll();
    }

    @PutMapping("u/byid")
    public CommonResult  modRoleByid(@RequestBody  Roles  roles){
        return   rolesService.modRoleByid(   roles);
    }



}
